#pragma once


/*
 * Simple INI file parser
 */

#include <string>
#include <map>


namespace bzbfile {


	struct INIFile; // Forward declaration


	/*
	 * Parses an INI file specified by <filename>
	 */

	INIFile parse_ini_file(const std::string &filename);


	/*
	 * Writes an INI file to a file named <filename>
	 */

	void write_ini_file(const INIFile &ini, const std::string &filename);


	struct INIFile {
		
		// Global properties
		// ["key"] -> "value"
		std::map<std::string, std::string> global_properties;

		// Properties inside sections
		// ["section"] -> ["key"] -> "value"
		std::map<std::string, std::map<std::string, std::string>> properties;


		INIFile() {}


		INIFile(const std::string &filename) {
			*this = parse_ini_file(filename);
		}


		inline void load(const std::string &filename) {
			*this = parse_ini_file(filename);
		}


		inline void write(const std::string &filename) {
			write_ini_file(*this, filename);
		}

	};


}
